package com.hghivln.erpwarehouse.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hghivln.erpwarehouse.system.common.lang.DataGridlView;
import com.hghivln.erpwarehouse.system.entity.Notice;
import com.hghivln.erpwarehouse.system.mapper.NoticeMapper;
import com.hghivln.erpwarehouse.system.service.NoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hghivln.erpwarehouse.system.vo.NoticeVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hghivln
 * @since 2021-06-26
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService {

    @Override
    public DataGridlView queryAllNotice(NoticeVo noticeVo) {
        Page<Notice> page = new Page<>(noticeVo.getPage(), noticeVo.getLimit());
        QueryWrapper<Notice> qw = new QueryWrapper<>();
        qw.like(!StringUtils.isEmpty(noticeVo.getTitle()),"title",noticeVo.getTitle());
        qw.like(!StringUtils.isEmpty(noticeVo.getOpername()),"opername",noticeVo.getOpername());
        qw.like(!StringUtils.isEmpty(noticeVo.getContent()),"content",noticeVo.getContent());
        qw.ge(noticeVo.getStartDate()!=null,"createtime",noticeVo.getStartDate());
        qw.le(noticeVo.getEndDate()!=null,"createtime",noticeVo.getEndDate());
        this.getBaseMapper().selectPage(page,qw);
        return new DataGridlView(page.getTotal(),page.getRecords());
    }
}
